import java.util.*;
class MyException extends Exception{
	public MyException() {}
	public MyException(String s) {
		super(s);
	} 
}
public class Main {
	double x,y;
	public String toString()
	{
		return "("+x+","+y+")";
	}
	public Main(double x,double y)
	{
		this.x=x;
		this.y=y;
	}
	public static Main[] fac(String x)throws MyException {
		String m[]=new String[2];
		String q[]=null;
		String k[]=new String[2];
		if(x.indexOf("+")==-1)
			throw new MyException("缺少加号");
		else
		{
			k=x.split("\\+");
			if(k[0].indexOf("(")==-1)
			{
				throw new MyException("缺少第一个左括号");		
			}
			else if(k[0].indexOf(")")==-1)
			{
				throw new MyException("缺少第一个右括号");		
			}
			else if(k[1].indexOf("(")==-1)
			{
				throw new MyException("缺少第二个左括号");		
			}
			else if(k[1].indexOf(")")==-1)
			{
				throw new MyException("缺少第二个右括号");		
			}
			else if(k[1].indexOf(",")==-1)
			{
				throw new MyException("缺少第二个逗号");		
			}
			else if(k[0].indexOf(",")==-1)
			{
				throw new MyException("缺少第一个逗号");		
			}
			else if(k[0].indexOf("i")==-1)
			{
				throw new MyException("缺少第一个i");
			}
			else if(k[1].indexOf("i")==-1)
			{
				throw new MyException("缺少第二个i");
			}
			else
			{
				m[0]=x.substring(x.indexOf("(")+1,x.indexOf(")")-1);
				m[1]=x.substring(x.indexOf("(")+1,x.indexOf(")")-1);
				Main p[]=new Main[2];
				q=m[0].split(",");
				p[0]=new Main(Double.parseDouble(q[0]),Double.parseDouble(q[1]));
				q=m[1].split(",");
				p[1]=new Main(Double.parseDouble(q[0]),Double.parseDouble(q[1]));
				return p;
			}	
		} 		
	}
	public static Main fac1(Main x,Main y)
	{
		return new Main(x.x+y.x,x.y+y.y);
	}
	public static void main(String[] args) {
		Main m[] = null,n;
		try {
			m=fac("(2,3i)+(4,5i)");
			System.out.println(fac1(m[0],m[1]));
		}catch(MyException e) {
			System.out.println(e);
		}
	}
}
